"""
斐波那契数列二
使用缓存 (memoization) 优化效率
"""

memo = {0: 0, 1: 1}


def fib(n):
    if n not in memo:
        memo[n] = fib(n-1) + fib(n-2)
    return memo[n]


def show_example():
    print('No. \tfib')
    print('-' * 60)

    for n in range(100):
        print(f'{n} \t{fib(n)}')


def main():
    show_example()


if __name__ == '__main__':
    main()
